/**
 * .
 * Copyright (c) 2013-2018 All Rights Reserved.
 */
package com.lcy.demotest.controller;

import com.lcy.demotest.model.User;
import com.lcy.demotest.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author playersix
 * @version $Id: UserController.java, v 0.1 2018-10-09 15:37 playersix Exp $$
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping
    public User add(User u) {
        return userService.add(u);
    }

    @DeleteMapping("/{id}")
    public int delete(@PathVariable Long id) {
        return userService.delete(id);
    }

    @PutMapping
    public int update(User u) {
        return userService.update(u);
    }

    @GetMapping("/{id}")
    public User get(@PathVariable Long id) {
        return userService.query(id);
    }
}
